<!--
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2023-09-14 12:31:39
 * @LastEditors: 卡卡 1071780426@qq.com
 * @LastEditTime: 2023-10-07 10:30:31
 * @FilePath: \mould\src\components\BehaViorManage\workYear\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div class="Control-1 mechanism_dialogS closure" id="comcn">
        <el-dialog :title="title" v-dialogDrag :visible.sync="visible" @close="closeDialog" :append-to-body="true" top="5%">
            <div class="dialogBody common commonClassDialog" :style="{ height: dialogHeight }" style="width: 100%">
                <tableData height="100%" :config="table_config" :dataList="tableData" :loading="loading" />
            </div>
            <div style="height: 50px;"></div>
        </el-dialog>
    </div>
</template>

<script>
import TableData from "@/components/HntManage/el-tables"; //主页面列表
import {
    getCreditEvaluationFormByFid,
} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "projectId",
        "status",
        "statusNum",
        "dataFid",
        "currentRow",
        "projectName",
        "stationType",
        "btnNum"
    ],
    data() {
        return {
            visible: "",
            title: "监理企业年度信用评价",
            isLock: false, // 控制按钮的disable属性
            btnStatus: [],
            dialogHeight: null,
            tableData: [],
            table_config: {},
            table_config1: {
                imgKeyWord: "url",
                fileKeyWord: "url",
                fileName: "fFileName",
                dialogHeight: '',
                thead: [{
                    label: "评价内容",
                    prop: "fEvaluationcontent",
                    minWidth: "80px",
                    align: "center",
                },
                {
                    label: '评价项目',
                    prop: 'fEvaluationproject',
                    minWidth: '80px',
                    align: "center",
                },
                {
                    label: "失信行为代码",
                    prop: "fBehaviorcode",
                    minWidth: "80px",
                    align: "center",
                },

                {
                    label: "失信行为",
                    prop: "fDishonestbehaviordesc",
                    minWidth: "85px",
                    align: "center",
                },
                {
                    label: "信用等级或扣分标准",
                    prop: "fCreditlevel",
                    minWidth: "85px",
                    align: "center",
                }, {
                    label: "监理自评(扣分)",
                    prop: "fJldeduction",
                    minWidth: "85px",
                    align: "center",
                    type: "number",
                },
                {
                    label: "监理扣分依据及情况说明",
                    prop: "fJldeductiondesc",
                    minWidth: "85px",
                    align: "center",
                    type: "text",

                }, {
                    label: "备注",
                    prop: "fNote",
                    minWidth: "85px",
                    align: "center",
                },

                ],
                isCheckBox: false,
                isIndex: true,
                isOperation: true,
                // 表格操作列
                operation: {
                    label: '操作',
                    width: '70',
                    detail: true,
                    prop: true,
                    cols: [],

                },
            },
            table_config2: {
                imgKeyWord: "url",
                fileKeyWord: "url",
                fileName: "fFileName",
                dialogHeight: '',
                thead: [{
                    label: "评价内容",
                    prop: "fEvaluationcontent",
                    minWidth: "80px",
                    align: "center",
                },
                {
                    label: '评价项目',
                    prop: 'fEvaluationproject',
                    minWidth: '80px',
                    align: "center",
                },
                {
                    label: "失信行为代码",
                    prop: "fBehaviorcode",
                    minWidth: "80px",
                    align: "center",
                },
                {
                    label: "失信行为",
                    prop: "fDishonestbehaviordesc",
                    minWidth: "85px",
                    align: "center",
                },
                {
                    label: "信用等级或扣分标准",
                    prop: "fCreditlevel",
                    minWidth: "85px",
                    align: "center",
                }, {
                    label: "监理自评(扣分)",
                    prop: "fJldeduction",
                    minWidth: "85px",
                    align: "center",
                    type: "number",
                },
                {
                    label: "监理扣分依据及情况说明",
                    prop: "fJldeductiondesc",
                    minWidth: "85px",
                    align: "center",
                    type: "text",
                }, {
                    label: "业主评分(扣分)",
                    prop: "fProprietordeduction",
                    minWidth: "85px",
                    align: "center",
                    type: "number",

                }, {
                    label: "业主扣分依据及情况说明",
                    prop: "fProprietordeductiondesc",
                    minWidth: "85px",
                    align: "center",
                    type: "text",
                }, {
                    label: "备注",
                    prop: "fNote",
                    minWidth: "85px",
                    align: "center",
                },
                ],
                isCheckBox: false,
                isIndex: true,
                isOperation: true,
                // 表格操作列
                operation: {
                    label: '操作',
                    width: '70',
                    detail: true,
                    prop: true,
                    cols: [],
                },
            },
            loading: false
        };
    },
    components: {
        TableData
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    console.log(888, newVal);
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },

        projectId: {
            handler(newVal) {
                if (newVal) {
                    this.getPerson(newVal);
                }
            },
            immediate: true,
        },
        status: {
            handler(newVal) {
                if (newVal) {
                    this.btnStatus = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {
                    this.edit(newVal);
                }
            },
            immediate: true,
        },
        dataFid: {
            handler(newVal) {
                if (newVal) {
                    this.currntData = newVal;
                    this.yj_searchForm(newVal);
                }
            },
            immediate: true,
        },
        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentStatus = newVal;
                }
            },
            immediate: true,
        },
        btnNum: {
            handler(newVal) {
                if (newVal) {
                    if (newVal == 1) {
                        this.table_config = this.table_config1
                    } else {
                        this.table_config = this.table_config2
                    }
                }
            },
            immediate: true,
        },
    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
        this.getHeight();
    },
    methods: {
        yj_searchForm(data) {
            this.loading = true;
            var that = this;
            var obj = {
                fId: data
            }
            that.tableData = []
            getCreditEvaluationFormByFid(obj)
                .then((res) => {
                    if (res.errcode == 0) {
                        that.loading = false;
                        if (this.userInfo.companyNature == '总监办') {
                            that.tableData = res.data.formList;
                        } else {
                            that.tableData = res.data.formList;
                        }
                    } else {
                        this.$message.error("列表数据获取失败", res.msg);
                        this.loading = false;
                    }
                })
                .catch((error) => {
                    this.$message.error("列表数据 接口出错", error.msg);
                    this.loading = false;
                });
        },
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        closeDialog() {
            this.$emit("close");
        },
    },
};
</script>
<style lang="less" scoped>
.comcn /deep/.el-dialog {
    width: 60% !important;
}
</style>
